#include <stdio.h>
#include <stdlib.h>
#include "grouping.h"

// 这里可以放置HeavyGuardian相关的工具函数
// 例如：重置计数器、获取统计信息等

// 获取HeavyGuardian的内存使用情况
/*size_t hg_memory_usage(const HeavyGuardian* hg) {
    if (!hg) return 0;
    
    size_t total = sizeof(HeavyGuardian);
    total += hg->config.depth * sizeof(HGBucket*);
    
    for (uint32_t d = 0; d < hg->config.depth; d++) {
        total += hg->config.width * sizeof(HGBucket);
        
        for (uint32_t w = 0; w < hg->config.width; w++) {
            total += hg->config.heavy_size * sizeof(HGCounter);
            total += hg->config.sparse_size * sizeof(HGCounter);
            
            // 计算字符串占用的内存
            for (uint32_t i = 0; i < hg->config.heavy_size; i++) {
                if (hg->buckets[d][w].heavy[i].item) {
                    total += strlen(hg->buckets[d][w].heavy[i].item) + 1;
                }
            }
            
            for (uint32_t i = 0; i < hg->config.sparse_size; i++) {
                if (hg->buckets[d][w].sparse[i].item) {
                    total += strlen(hg->buckets[d][w].sparse[i].item) + 1;
                }
            }
        }
    }
    
    return total;
}*/

// 重置HeavyGuardian（清空所有计数器）
/*void hg_reset(HeavyGuardian* hg) {
    if (!hg) return;
    
    hg->total_count = 0;
    
    for (uint32_t d = 0; d < hg->config.depth; d++) {
        for (uint32_t w = 0; w < hg->config.width; w++) {
            for (uint32_t i = 0; i < hg->config.heavy_size; i++) {
                free(hg->buckets[d][w].heavy[i].item);
                hg->buckets[d][w].heavy[i].item = NULL;
                hg->buckets[d][w].heavy[i].count = 0;
            }
            
            for (uint32_t i = 0; i < hg->config.sparse_size; i++) {
                free(hg->buckets[d][w].sparse[i].item);
                hg->buckets[d][w].sparse[i].item = NULL;
                hg->buckets[d][w].sparse[i].count = 0;
            }
        }
    }
}*/